import React                from 'react';
import {connect}            from 'react-redux';

import Toast                from '../components/toast/Toast';
import {subRoutes}          from '../config/Navigator';
import {resetErrorMessage}  from '../actions';

const App = ({routes, errorMessage, resetErrorMessage}) => (
    <div className="app">
        <Toast open={errorMessage !== null} onRequestClose={resetErrorMessage}>{errorMessage}</Toast>
        {subRoutes(routes)}
    </div>
);

export default connect(({errorMessage}) => ({errorMessage}), {resetErrorMessage})(App);


